package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglSfrw;
import com.xveshe.admin.service.IXsglSfrwService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 收发任务Controller
 *
 * @author geyasong
 * @date 2024-11-06
 */
@RestController
@RequestMapping("/admin/sfrw")
public class XsglSfrwController extends BaseController
{
    @Autowired
    private IXsglSfrwService xsglSfrwService;

    /**
     * 查询收发任务列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglSfrw xsglSfrw)
    {
        startPage();
        List<XsglSfrw> list = xsglSfrwService.selectXsglSfrwList(xsglSfrw);
        return getDataTable(list);
    }

    /**
     * 导出收发任务列表
     */
    @PreAuthorize("@ss.hasPermi('admin:sfrw:export')")
    @Log(title = "收发任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglSfrw xsglSfrw)
    {
        List<XsglSfrw> list = xsglSfrwService.selectXsglSfrwList(xsglSfrw);
        ExcelUtil<XsglSfrw> util = new ExcelUtil<XsglSfrw>(XsglSfrw.class);
        util.exportExcel(response, list, "收发任务数据");
    }

    /**
     * 获取收发任务详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglSfrwService.selectXsglSfrwById(id));
    }

    /**
     * 新增收发任务
     */
    @PreAuthorize("@ss.hasPermi('admin:sfrw:add')")
    @Log(title = "收发任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglSfrw xsglSfrw)
    {
        return toAjax(xsglSfrwService.insertXsglSfrw(xsglSfrw));
    }

    /**
     * 修改收发任务
     */
    @PreAuthorize("@ss.hasPermi('admin:sfrw:edit')")
    @Log(title = "收发任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglSfrw xsglSfrw)
    {
        return toAjax(xsglSfrwService.updateXsglSfrw(xsglSfrw));
    }

    /**
     * 删除收发任务
     */
    @PreAuthorize("@ss.hasPermi('admin:sfrw:remove')")
    @Log(title = "收发任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglSfrwService.deleteXsglSfrwByIds(ids));
    }
}
